package com.sunday.redisson.lambda.toolkit.support;

import com.sunday.common.core.constants.StringConstants;
import com.sunday.common.core.enums.ErrorCodeEnum;
import com.sunday.common.core.lambda.toolkit.support.ColumnMapper;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.lang.reflect.Field;

/**
 * 注解属性
 *
 * @author zsy
 * @since 2022/10/20
 */
@Data
@AllArgsConstructor
public class LockColumnMapper implements ColumnMapper {

    /**
     * redis key 前缀
     */
    private String prefix;

    /**
     * 异常时报错码
     */
    private ErrorCodeEnum errorCodeEnum;

    /**
     * 自定义错误话术
     */
    private String message;

    /**
     * 属性
     */
    private Field field;

    @Override
    public String getColumn() {
        return prefix;
    }

    @Override
    public String getColumnSelect() {
        return prefix + StringConstants.UNDERSCORE;
    }

    public static LockColumnMapper of(String prefix, ErrorCodeEnum errorCodeEnum, String message, Field field) {
        return new LockColumnMapper(prefix, errorCodeEnum, message, field);
    }


}
